#define _CRT_SECURE_NO_WARNINGS 1
class Solution {
public:
    string longestPalindrome(string s) {
        int n = s.size();
        vector<vector<bool>> dp(n, vector<bool>(n));
        int maxlen = 1;
        int m = 0;
        for (int i = n - 1;i >= 0;i--)
        {
            for (int j = i;j < n;j++)
            {
                if (s[i] == s[j])
                {
                    dp[i][j] = i + 1 < j ? dp[i + 1][j - 1] : true;
                }
                if (dp[i][j])
                {
                    int len = j - i + 1;
                    if (len > maxlen)
                    {
                        maxlen = len;
                        m = i;
                        cout << maxlen << " " << m << endl;
                    }
                }
            }
        }
        // for(int i =0;i<n;i++)
        // {
        //     for(int j = 0;j<n;j++)
        //     {
        //         cout<<dp[i][j]<<" ";
        //     }
        //     cout<<endl;
        // }
        return s.substr(m, maxlen);
    }
};